package com.kly.user.enums;

public enum AppEnum {
    MEBOO(1, "MEBOO", "sparksy"),
    MECHAT(2, "MECHAT", "mechat"),
    TOUCHU(3, "TOUCHU", "touchu"),
    PP(4, "PP", "pp"),
    MEBOO_IOS(5, "MEBOO_IOS", "sparksy_ios"),
    NOT_EXIST(999999, "not exist", "not exist"),
    ;
    private final Integer AppCode;

    private final String description;

    private String userAppFlag;

    AppEnum(Integer appCode, String description, String userAppFlag) {
        AppCode = appCode;
        this.description = description;
        this.userAppFlag = userAppFlag;
    }

    public static AppEnum getEnumByUserAppFlat(String userAppFlag) {
        AppEnum appEnum = AppEnum.NOT_EXIST;
        for (AppEnum value : AppEnum.values()) {
            if (userAppFlag.equals(value.getUserAppFlag())) {
                appEnum = value;
                break;
            }
        }

        return appEnum;
    }

    public String getUserAppFlag() {
        return userAppFlag;
    }

    public AppEnum setUserAppFlag(String userAppFlag) {
        this.userAppFlag = userAppFlag;
        return this;
    }

    AppEnum(Integer appCode, String description) {
        AppCode = appCode;
        this.description = description;
    }

    public Integer getAppCode() {
        return AppCode;
    }

    public String getDescription() {
        return description;
    }

    public static AppEnum fromType(String type) {

        for (AppEnum appCode : values()) {
            if (appCode.getAppCode().toString().equals(type)) {
                return appCode;
            }
        }
        return null;
    }
}
